//
//  ZCMeViewController.m
//  ZCBaiSi
//
//  Created by zc on 16/7/6.
//  Copyright © 2016年 zc. All rights reserved.
//

#import "ZCMeViewController.h"
#import "ZCSettingViewController.h"
#import "ZCMeFooterView.h"
@implementation ZCMeViewController

- (instancetype)init{
    return [self initWithStyle:UITableViewStyleGrouped];
}

- (void)viewDidLoad{
    [super viewDidLoad];
    
    [self setupTab];
    
    [self setupNav];
}

- (void)setupTab{
    self.tableView.sectionHeaderHeight = 0;
    self.tableView.sectionFooterHeight = ZCMargin;
    self.tableView.contentInset = UIEdgeInsetsMake(ZCMargin - 35, 0, 0, 0);
    //设置footer
    ZCMeFooterView *footerView = [[ZCMeFooterView alloc]init];
    self.tableView.tableFooterView = footerView;
}

- (void)setupNav{
    //标题
    self.navigationItem.title = @"我的";
    //右边设置按钮
    
    UIBarButtonItem *settingItem = [UIBarButtonItem itemWithImage:@"mine-setting-icon" highImage:@"mine-setting-icon-click" target:self action:@selector(settingClick)];
    
    UIBarButtonItem *moonItem = [UIBarButtonItem itemWithImage:@"mine-moon-icon" highImage:@"mine-moon-icon-click" target:self action:@selector(moonClick)];
    
    self.navigationItem.rightBarButtonItems = @[settingItem,moonItem];

}

 

- (void)settingClick{
    ZCSettingViewController *setting = [[ZCSettingViewController alloc]initWithStyle:UITableViewStyleGrouped];
    [self.navigationController pushViewController:setting animated:YES];
}

- (void)moonClick{
    ZCLogFunc
}

#pragma mark -- tableViewDelegate

- (NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 2;
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    //1.重用标识
    static NSString *ID = @"cell";
    //2。从缓存池中取
    UITableViewCell *cell = [tableView dequeueReusableCellWithIdentifier:ID];
    //3.如果为空就手动创建
    if (!cell) {
        cell = [[UITableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:ID];
        cell.backgroundView = [[UIImageView alloc]initWithImage:[UIImage imageNamed:@"mainCellBackground"]];
    }
    //设置数据
    if (indexPath.section == 0) {
        cell.textLabel.text = @"登录/注册";
        cell.imageView.image = [UIImage imageNamed:@"setup-head-default"];
    }else{
        cell.textLabel.text = @"离线下载";
        cell.imageView.image = nil;
    }
    //设置最右边的图片
   // tableView.inputAccessoryView = [UIImageView alloc]initWithImage:<#(nullable UIImage *)#>
    
    return cell;
}

- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    if (indexPath.section == 2) {
        return 200;
    }
    return 44;
}

- (void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    
}


@end
